package com.sgb.kjwl.utils;

import android.content.Context;
import android.text.TextUtils;
import android.widget.EditText;
import android.widget.TextView;

import com.sgb.kjwl.R;
import com.swgk.core.customview.ItemInputTextView;
import com.swgk.core.favor.Default;
import com.swgk.core.util.MToast;

/**
 * @author younghow
 * @date 2021/4/23
 */
public class UploadCheckHelper {

    public static boolean textCheck(Context context,TextView[] views, String[] toastStr,boolean isNeed){
        for (int i = 0; i < views.length; i++) {
            if (!isNeed && views[i].getId() == R.id.tv_fragment_trade_publish_select_new_or_old){
                continue;
            }

            if (views[i] instanceof EditText && "".equals(views[i].getText().toString())){
                MToast.showToast(context,"请填写"+toastStr[i]);
                return false;
            }

            if (views[i] != null && "".equals(views[i].getText().toString())){
                MToast.showToast(context,"请选择"+toastStr[i]);
                return false;
            }
        }

        return true;
    }

    public static boolean textCheck(Context context,TextView[] views, String[] toastStr){
        for (int i = 0; i < views.length; i++) {
            if (views[i] instanceof EditText && "".equals(views[i].getText().toString())){
                MToast.showToast(context,"请输入"+toastStr[i]);
                return false;
            }

            if (views[i] != null && "".equals(views[i].getText().toString())){
                MToast.showToast(context,"请选择"+toastStr[i]);
                return false;
            }
        }

        return true;
    }


    public static boolean textCheckForCrew (Context context, ItemInputTextView[] views,Boolean isVisible){
        for (ItemInputTextView view : views) {
            if (!isVisible && view.getId() == R.id.et_salary){
                continue;
            }

            if (TextUtils.isEmpty(view.getContent())) {
                MToast.showToast(context, view.getHint());
                return false;
            }
        }

        return true;
    }
}
